layui.use(['table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    /**
     * 货物搬运管理
     */
    var HxBasicGoodsGjkcWgx = {
        tableId: "hxBasicGoodsGjkcWgxTable"
    };

    /**
     * 初始化表格的列
     */
    HxBasicGoodsGjkcWgx.initColumn = function () {
        return [[
            {field: 'goodsNumber', sort: true, title: '编号'},
            {field: 'goodsName', sort: true, title: '商品名称'},
            {field: 'goodsPcode69', sort: true, title: '商品码'},
            {field: 'goodsXcode69', sort: true, title: '商品码2'},
            {field: 'goodsHcode69', sort: true, title: '商品码3'},
            {field: 'dismantlingParts', sort: true, title: '是否拆零'},
            {field: 'goodsHelpcode', sort: true, title: '助记码'},
            {field: 'goodsHeavybubble', title: '重泡货'},
            {field: 'goodsSpecs', sort: true, title: '规格'},
            {field: 'goodsBigtype', sort: true, title: '分类'},
            {field: 'goodsBrand', sort: true, title: '品牌'},
            {field: 'jibenUnit', sort: true, title: '基本单位'},
            {field: 'kcUnit', sort: true, title: '库存单位'},
            {field: 'kcRate', sort: true, title: '库存换算率'},
            {field: 'cgUnit', sort: true, title: '采购单位'},
            {field: 'cgRate', sort: true, title: '采购换算率'},
            {field: 'pfUnit', sort: true, title: '批发单位'},
            {field: 'pfRate', sort: true, title: '批发换算率'},
            {field: 'psUnit', sort: true, title: '配送单位'},
            {field: 'psRate', sort: true, title: '配送换算率'},
            {field: 'anquanNum', sort: true, title: '安全库存值'},
            {field: 'goodsBottom', sort: true, title: '底'},
            {field: 'goodsLamination', sort: true, title: '叠层'},
            {field: 'goodsTraylayer', sort: true, title: '托层'},
            {field: 'goodsSupportvolume', sort: true, title: '每托存量'},
            {field: 'length', sort: true, title: '长'},
            {field: 'height', sort: true, title: '高'},
            {field: 'width', sort: true, title: '宽'},
            {field: 'goodsWeight', sort: true, title: '采购重量'},
            {field: 'goodsVolume', sort: true, title: '采购体积'},
            {field: 'goodsChargingCg', sort: true, title: '采购价'},
            {field: 'goodsChargingPs', sort: true, title: '配送价'},
            {field: 'goodsChargingPf', sort: true, title: '批发价'},
            {field: 'goodsWarranty', sort: true, title: '保质期'},
            {field: 'goodsXlbId', sort: true, title: '新零帮商品id'},
            {field: 'goodsNodes', sort: true, title: '备注'},
            {field: 'createTime', sort: true, title: '创建时间'},
            {field: 'updateTime', sort: true, title: '修改时间'},
            {field: 'createName', sort: true, title: '创建用户'},
            {field: 'updateName', sort: true, title: '修改用户'},
        ]];
    };

    /**
     * 点击查询按钮
     */
    HxBasicGoodsGjkcWgx.search = function () {
        var queryData = {};
        queryData['warehouseId'] = $("#storehouseId").val();
        table.reload(HxBasicGoodsGjkcWgx.tableId, {
            where: queryData, page: {curr: 1},
             done:function () {
            }
        });
    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + HxBasicGoodsGjkcWgx.tableId,
        url: Feng.ctxPath + '/hxBasicGoods/gjkcWgxList?warehouseId='+$("#storehouseId").val(),
        page: true,
        limit: 20,
        height: "full-60",
        // toolbar: '#toolbarfrom',
        cellMinWidth: 100,
        cols: HxBasicGoodsGjkcWgx.initColumn()
    });

    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        HxBasicGoodsGjkcWgx.search();
    });

});
